// /**
//  * 描述：路由文件
//  */
// import App from '../App';
import main from '@/page/main/main';
import indexRouter from '@/page/main/indexRouter';

const user = r => require.ensure([], () => r(require('../page/main/userManage/user/index')), 'user'); // 用户页面
const role = r => require.ensure([], () => r(require('../page/main/userManage/role/index')), 'role'); // 角色管理
const org = r => require.ensure([], () => r(require('../page/main/userManage/org/index')), 'org'); // 组织管理

// 定位管理
const realTime = r => require.ensure([], () => r(require('../page/main/position/realTime/index')), 'realTime'); // 实时定位
const historyTrack = r => require.ensure([], () => r(require('../page/main/position/historyTrack/index')), 'historyTrack'); // 轨迹回放
const fullChartMonitoring = r => require.ensure([], () => r(require('../page/main/position/fullChartMonitoring/index')), 'fullChartMonitoring'); // 全图监控

// 车辆及司机信息管理
const carBaseInfo = r => require.ensure([], () => r(require('../page/main/infoManage/car/index')), 'carBaseInfo'); // 车辆基础信息管理
const carAddorEdit = r => require.ensure([], () => r(require('../page/main/infoManage/car/info')), 'carAddorEdit'); // 车辆基础信息新增及编辑

// 司机管理
const driver = r => require.ensure([], () => r(require('../page/main/infoManage/driver/index')), 'driver'); // 司机基础信息管理
const driverAddorEdit = r => require.ensure([], () => r(require('../page/main/infoManage/driver/info')), 'driverAddorEdit'); // 司机新增编辑

// 设备管理
const deviceGPS = r => require.ensure([], () => r(require('../page/main/infoManage/device/gps/index')), 'deviceGPS'); // 设备基础信息管理-gps
const deviceAddorEdit = r => require.ensure([], () => r(require('../page/main/infoManage/device/gps/info')), 'deviceAddorEdit'); // 设备新增编辑
const deviceTY = r => require.ensure([], () => r(require('../page/main/infoManage/device/ty/index')), 'deviceTY'); // 设备基础信息管理-TY

// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
  path: '/login',
  name: 'login',
  meta: {
    title: 'Login - 登录'
  },
  component: () => import('@/page/login/login')
};

export const page404 = {
  path: '/*',
  name: 'error-404',
  meta: {
    title: '404-页面不存在'
  },
  component: () => import('@/page/404/404')
};

export const locking = {
  path: '/locking',
  name: 'locking',
  component: () => import('@/components/main-components/lockscreen/components/locking-page.vue')
};

// 作为Main组件的子页面展示但是不在左侧菜单显示的路由写在otherRouter里
export const otherRouter = {
  path: '/',
  name: 'otherRouter',
  redirect: '/home',
  component: main,
  children: [
    { path: 'home', title: '首页', name: 'home', component: () => import('@/page/main/home/home.vue') },
    { path: 'position/carBaseInfo/carAddorEdit', title: '车辆基础信息新增编辑', name: 'carAddorEdit', component: carAddorEdit },
    { path: 'position/historyTrack', title: '轨迹回放', name: 'historyTrack', component: historyTrack }, // 轨迹回放
    { path: 'position/realTime', title: '实时位置', name: 'realTime', component: realTime }, // 实时位置
    { path: 'position/driver/driverAddorEdit', title: '司机信息新增编辑', name: 'driverAddorEdit', component: driverAddorEdit },
    { path: 'position/device/deviceAddorEdit', title: '设备新增编辑', name: 'deviceAddorEdit', component: deviceAddorEdit }
  ]
};

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
export const appRouter = [
  {
    id: 1,
    path: '/userManage',
    icon: 'person',
    name: 'userManage',
    title: '用户中心',
    component: main,
    children: [
      // 用户中心
      {
        id: 2,
        path: 'user',
        title: '用户管理',
        name: 'user',
        component: user
      },
      // 角色管理
      {
        id: 3,
        path: 'user/role',
        title: '角色管理',
        name: 'role',
        component: role
      },
      // 组织管理
      {
        id: 4,
        path: 'user/org',
        title: '机构管理',
        name: 'org',
        component: org
      }
    ]
  },
  {
    id: 5,
    path: '/position',
    icon: 'map',
    name: 'position',
    title: '定位管理',
    component: main,
    children: [
      // 车辆全图监控
      {
        path: 'fullChartMonitoring',
        title: '车辆全图监控',
        name: 'fullChartMonitoring',
        component: fullChartMonitoring
      },
      // 信息管理
      {
        path: 'carBaseInfo',
        title: '车辆基础信息管理',
        name: 'carBaseInfo',
        component: carBaseInfo
      },
       // 司机管理
       {
        path: 'driver',
        title: '司机管理',
        name: 'driver',
        component: driver
      },
      // 设备管理
      {
      path: 'device',
      title: '设备管理',
      name: 'device',
      component: indexRouter,
        children: [
          {
            path: 'gps',
            title: 'GPS管理',
            name: 'deviceGPS',
            component: deviceGPS
          },
          {
            path: 'ty',
            title: '天眼管理',
            name: 'deviceTY',
            component: deviceTY
          }
        ]
      }
      ]
    }
];

// 所有上面定义的路由都要写在下面的routers里
export const routes = [
  loginRouter,
  otherRouter,
  locking,
  ...appRouter,
  page404
];
